<?php
/**
 * @file $HeadURL: imagecollectivepic.php $
 * @author $Author: DongJC (dongjianchang@haibao.com) $
 * @date $Date: 2015-4-6 12:52:27 $
 * @brief 
 */
namespace haibao\cms\data\imagecollective;


class ImageCollectivePic extends \haibao\cms\data\BaseMysql{
    
    const IMAGECOLLECTIVEPRO = 1;
    const IMAGECOLLECTIVEKEYWORDS = 2;
    const EVENTIMAGECOLLECTIVE = 3;
    
	public function __construct($type = 0){
	    if($type == self::IMAGECOLLECTIVEPRO){
	        parent::__construct('\haibao\cms\model\data\imagecollective\ImageCollectivePro');
	    }elseif ($type == self::IMAGECOLLECTIVEKEYWORDS){
	        parent::__construct('\haibao\cms\model\data\imagecollective\ImageCollectiveKeywords');
	    }elseif ($type == self::EVENTIMAGECOLLECTIVE){
	        parent::__construct('\haibao\cms\model\data\EventImageCollective');
	    }else{
	        parent::__construct('\haibao\cms\model\data\imagecollective\ImageCollectivePic');
	    }
	}
	
	public function saveImageCollectivePicInfo($model){
		$sql="update ImageCollectivePic set Description = %s where ImageCollectiveId = %s and ImageId = %s ";
		$this->query($sql,array($model->Description,$model->ImageCollectiveId,$model->ImageId));
	}
	
	public function hasImage($imageCollectiveId){
		$data = 0;
		$sql="select count(Id) as count from ImageCollectivePic where ImageCollectiveId = %s ";
		$result = $this->query($sql,array($imageCollectiveId));
		while($result->fetch_assoc()){
			$data = $result->getData('count'); 	
		}
		return $data;
	}
}
